透過 快進合併 只有在分支歷史呈連續的後代直線時,才可能實現線性歷史。一旦主分支與功能分支分叉,快進合併中簡單的「指標移動」便在數學上變得不可能。
1. 可見的差異
快進合併不會 反映在專案歷史上 這表示該分支的獨特存在於整合後幾乎被抹除。相比之下,三路合併則保留了並行工作的敘事脈絡。
2. 歷史學家原則
永久的 主分支 扮演著整個專案的歷史學家角色。它只能記錄我們允許它看到的事物;當路徑分叉時,我們被迫創建一個新的「事件」——一個 合併提交——以彌合差距,調和兩個同時演變的不同現實。
3. 檢測分叉
使用 git log --oneline開發者可藉此視覺化路徑分叉的位置。若『主分支』自你建立分支以來已有前進,Git 就無法在不遺失主分支新工作的情況下向前滑動指標。
main.py
TERMINALbash — 80x24
> Ready. Click "Run" to execute.
>
QUESTION 1
[Short Answer] What is the tangible distinction between fast-forward merges and 3-way merges regarding history?
Fast-forward merges are not reflected in the project history.
3-way merges delete the feature branch history.
✅ Correct!
Correct. Fast-forwarding simply moves a pointer, whereas a 3-way merge creates a new commit that records the integration.❌ Incorrect
Recall that 3-way merges preserve parallel work, while fast-forwarding leaves no trace of the branch.QUESTION 2
[Short Answer] Which branch is described as the 'historian' for the entire project?
The feature branch.
The permanent master branch.
✅ Correct!
Correct. The master branch serves as the authoritative timeline of the project.❌ Incorrect
The master branch acts as the historian; feature branches are often temporary.QUESTION 3
[Short Answer] [Short Answer] Create a hotfix branch named 'news-hotfix' from master to address an immediate site update.
git checkout -b news-hotfix master
git branch news-hotfix && git checkout news-hotfix
✅ Correct!
Both 'git checkout -b' and the two-step branch/checkout sequence are correct.❌ Incorrect
Ensure you are using the branch name 'news-hotfix' as requested.QUESTION 4
Which command is most effective for visualizing where branch paths split?
git commit -a
git log --oneline
git status
git merge --ff-only
✅ Correct!
Git log --oneline (especially with --graph) shows the divergence visually.❌ Incorrect
Status shows current changes, but log shows the historical divergence.QUESTION 5
Why is a fast-forward merge 'mathematically impossible' after divergence?
Because the pointer would have to move to a path that isn't a direct descendant.
Because Git prohibits merges after security patches.
✅ Correct!
A fast-forward requires a linear ancestor-descendant relationship.❌ Incorrect
It is about the structure of the commit graph, not the content of the files.Case Study: Analyzing Divergence
Interpreting failed fast-forwards
[Reading Context: Take a moment to examine why the current merge couldn't be a fast-forward one. . . We’re left with a new way to combine branches: the 3-way merge.] Imagine you branch off 'master' for a 'sidebar' feature. While you work, a colleague commits a critical patch to 'master'. You now try to merge back.
Q
Take a moment to examine why the current merge couldn't be a fast-forward one. How could Git have walked the crazy pointer over to the tip of the master branch without losing the unique work that was just added to the master branch? [Difficulty: Stem Words: 38, Length: Short]
Solution:
[⚠️ SYSTEM_WARNING: Missing Reference Answer. Instructor must manually provide the answer during class.]
[⚠️ SYSTEM_WARNING: Missing Reference Answer. Instructor must manually provide the answer during class.]
Q
Difficulty: Stem Words: 18, Length: Short. [Short Answer] [Short Answer] What command would you use to verify this divergence visually in the terminal?
Solution:
The command is
The command is
git log --oneline --graph --all. This allows the developer to see the 'Y' shape where master and the feature branch separated.